Skip to content

Add IOB display option for contact watch face#512

Open
luborjurena wants to merge 7 commits intoloopandlearn:devfrom
luborjurena:dev-iob-contact
Open

Add IOB display option for contact watch face#512
luborjurena wants to merge 7 commits intoloopandlearn:devfrom
luborjurena:dev-iob-contact

Conversation

@luborjurena
Copy link

Extends the contact feature to support showing IOB (Insulin on Board) alongside the existing trend and delta options. Users can now choose to include IOB in the main BG contact or create a separate IOB contact.

luborjurena and others added 7 commits January 26, 2026 14:09
Extends the contact feature to support showing IOB (Insulin on Board)
alongside the existing trend and delta options. Users can now choose to
include IOB in the main BG contact or create a separate IOB contact.
Fix delayed IOB contact update with latest value
Allow selecting which contact to include Trend, Delta, or IOB into,
instead of only including into the BG contact. When a field is set
to "Separate", it becomes available as a target for other fields.
This enables groupings like BG+Trend in one contact and Delta+IOB
in another.
Adds a "Color Mode" setting with two options:
- Static: Uses the selected text color (existing behavior)
- Dynamic: Colors text based on BG range using raw mg/dL value
  - Green: In range
  - Yellow: High (>= highLine)
  - Red: Low (<= lowLine)

When Dynamic mode is selected, the text color picker is hidden since
the color is determined automatically based on glucose thresholds.

Files changed:
- ContactColorMode.swift: New enum with color logic
- Storage.swift: Add contactColorMode setting
- ContactSettingsViewModel.swift: Add colorMode property
- ContactSettingsView.swift: Add Color Mode picker
- ContactImageUpdater.swift: Use raw BG value for color calculation
- project.pbxproj: Add ContactColorMode.swift to project
Add flexible contact grouping with target selection
Allow static and dynamic colors based on BG range (inspired by Trio)
@bjorkert
Copy link
Contributor

Hi,

Thanks for the contribution!
To make the review easier, especially for those who don’t read the code in detail, could you please add before-and-after screenshots for the affected views?

@luborjurena
Copy link
Author

Hello,

First, I added the feature to add IOB.
Then, I added the option to choose where to group the next value.
Finally, I added colors, inspired by Trio.

Here are screenshots:
incoming-1ACD1481-9C9F-470D-8B50-5DA1DCFD8751
Snímka obrazovky 2026-01-29 o 21 23 09

@bjorkert
Copy link
Contributor

Hi @luborjurena, and thank you for your contribution. A few comments and questions, let me know if I misunderstood anything.

  1. ContactColorMode.parseBGValue() is dead code
    parseBGValue(_:) in ContactColorMode.swift:81-87 is never called anywhere in this PR or called from textColor(for:).
    Not sure if this is code that should be used somewhere?

  2. Dynamic color applies to ALL contact types, not just BG
    textColor() in ContactImageUpdater uses the dynamic color for every contact (Trend, Delta, IOB), not just BG. A separate IOB contact showing "2.5U" will be colored green/yellow/red based on the BG value, which may confuse users. Consider whether IOB/Delta/Trend contacts should always use the static color?

  3. Potential double-update on device status
    In DeviceStatus.swift:302-310, a contact update is triggered when IOB is enabled. But BGData.swift already triggers a contact update on every BG reading. If a device status update arrives shortly after a BG update, you get two rapid contact writes. Consider debouncing or checking if the IOB value actually changed before triggering, this could cause delays but doubling (or more) the amounts of updates to the contacts might be problematic.

  4. iobText default is empty string, others have defaults
    Observable.swift — iobText defaults to "" while directionText defaults to "-" and deltaText to "+0". If a contact update fires before device status loads, the IOB field will render as blank. Consider defaulting to "--" for consistency.

  5. Minor: stale strikethrough only on BG type before, now on all
    The old code only applied strikethroughStyle to the BG contact type. The new code applies it to all contact types, was this intentional? We could have a stale bg while IOB is up to date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants